package com.samehope.ar.service.impl;

import com.samehope.ar.dto.TaskPointQueryParam;
import com.samehope.ar.entity.TaskItem;
import com.samehope.ar.entity.TaskPoint;
import com.samehope.ar.mapper.TaskPointMapper;
import com.samehope.ar.service.ITaskItemService;
import com.samehope.ar.service.ITaskPointService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.samehope.ar.util.SessionUtil;
import com.samehope.ar.vo.TaskItemDataVO;
import com.samehope.ar.vo.TaskPointDataVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 巡检点快照 服务实现类
 * </p>
 *
 * @author Zhang Luo
 * @since 2019-12-23
 */
@Service
public class TaskPointServiceImpl extends ServiceImpl<TaskPointMapper, TaskPoint> implements ITaskPointService {

    @Autowired
    private ITaskItemService taskItemService;

    /**
     * 查询该任务的巡检点详情
     * @param taskId
     * @return
     */
    @Override
    public List<TaskPointDataVO> findByTaskOrPoint(Long taskId, Long patrolPointId){

        List<TaskPointDataVO> taskPoints = this.baseMapper.findByTaskOrPoint(SessionUtil.getCompanyId()
                , SessionUtil.getProjectId()
                , taskId
                , patrolPointId);

        return taskPoints;
    }

    /**
     * 生成点位快照信息
     */
    @Override
    public void insertAll(){
        this.baseMapper.insertAll();
    }

    /**
     * 生成点位快照信息
     */
    @Override
    public void insertByTask(Long taskId, Long routeId){
        this.baseMapper.insertByTask(taskId, routeId);
    }

    /**
     * 删除快照信息
     * @param taskTime
     */
    @Override
    public void delByTaskTime(String taskTime){
        this.baseMapper.delByTaskTime(taskTime);
    }

    /**
     * 删除未执行任务快照
     * @param planId
     */
    @Override
    public void delByUnFinishTask(Long planId){
        this.baseMapper.delByUnFinishTask(planId, SessionUtil.getUserId());
    }

    @Override
    public void delByTaskId(Long taskId){
        this.baseMapper.delByTaskId(taskId, SessionUtil.getUserId());
    }
}
